<template>
  <div>
    <el-row>
      <el-col :span="3"><el-tag type="success">今日已检查{{ finish_check_count }}人</el-tag></el-col>
      <el-col :span="3"><el-tag type="warning">当前有{{ wait_check_count }}人在排队</el-tag></el-col>
      <el-col :span="18"> </el-col>
    </el-row>
    <el-divider></el-divider>
    <div style="font-size:20px;text-align:left">
      <i class="el-icon-document-checked">检查申请</i>
    </div>
    <el-divider></el-divider>
    <el-row :gutter="20">
      <el-col :span="6"><el-input v-model="input_patient_id" placeholder="请输入患者病历号"></el-input></el-col>
      <el-col :span="6"><el-input v-model="input_patient_name" placeholder="请输入患者姓名"></el-input></el-col>      
      <el-col :span="2"><el-button @click="selectpatients">搜索</el-button></el-col>
      <el-col :span="10"> </el-col>
    </el-row>
    <el-divider></el-divider>
    <el-table
      :data="wait_check"      style="width: 80%">
      <el-table-column        type="index"     label="编号"        width="80"></el-table-column>
      <el-table-column        prop="realName"        label="患者姓名"        width="180"></el-table-column>
      <el-table-column        prop="caseNumber"        label="患者病历号">     </el-table-column>
      <el-table-column label="操作">
      <template #default="scope">
        <el-button   size="mini" @click="createCheckApply(scope.$index, scope.row)">进行检查</el-button>
        <el-button size="mini" >跳过</el-button>
        <el-button size="mini" >叫号</el-button>
      </template>
    </el-table-column>
    </el-table>
    <el-divider></el-divider>
    <el-pagination
        :default-current-page="currPage"
    :page-size="pageSize"
    :total="totalCount"
    @current-change="wait_patient_table_change"
    layout="prev, pager, next">
  </el-pagination>
  </div>
</template>
<script>
    import {setSessionStorage} from "@/util/common";
    import {ElMessage} from "element-plus";

    export default {
      data() {
        return {
          currPage:1,
          input_patient_id:'',
          input_patient_name:'',
          pageSize:5,//每页显示行数
          totalCount:0,
          finish_check_count:0,//已经检查完成人数
          wait_check_count:0,//等待检查人数
          wait_check: [],

        }
      },
      methods:{

        wait_patient_table_change:function (currPage){
          this.currPage=currPage
        },
        //得到已缴费的患者
        selectpatients:function ()
        {
          let value={
            realName:'',
            caseNumber:''
          }
         let url=`http://localhost:8092/register/selectpatients/${this.currPage}`
          this.$axios.post(url,value).then(resp=>{
            this.wait_check=resp.data.result
            this.totalCount=resp.data.total

          })
        },
        //进行检查
        createCheckApply:function (index,row)
        {

          setSessionStorage("patient",row)
          ElMessage({
            type:"info",
            message:"检查申请成功！"
          })
        }
      },
      mounted() {
      }
    }
  </script>